package com.yzh.pinboard.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;

import com.yzh.pinboard.R;

/**
 * Created by Administrator on 2017/3/7.
 */

public class CameraOrPhotoDialog extends Dialog implements View.OnClickListener {


    private onChooseListener mOnChooseListener;

    public CameraOrPhotoDialog(@NonNull Context context) {
        super(context, R.style.Translucent_NoTitle);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_camera_or_photo);
        Button camera = (Button) findViewById(R.id.btn_camera);
        Button photo = (Button) findViewById(R.id.btn_photo);
        camera.setOnClickListener(this);
        photo.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int i = v.getId();
        if (i == R.id.btn_camera) {
            if (mOnChooseListener != null) {
                mOnChooseListener.chooseCamera();
            }
            dismiss();

        } else if (i == R.id.btn_photo) {
            if (mOnChooseListener != null) {
                mOnChooseListener.choosePhoto();

            }
            dismiss();

        }
    }

    public void setOnChooseListener(onChooseListener onChooseListener) {
        mOnChooseListener = onChooseListener;
    }

    public interface onChooseListener {
        void chooseCamera();

        void choosePhoto();
    }
}
